<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>订单列表</title>
		<meta name="Description" content="" />
		<meta name="Keywords" content="" />
		<meta name="format-detection" content="telephone=no, email=no" />
		<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
		<!-- 忽略页面中的数字识别为电话，忽略email识别 -->
		<meta name="applicable-device" content="mobile" />
		<meta name="apple-mobile-web-app-title" content="" />
		<!-- 添加到主屏后的标题（iOS 6 新增） -->
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<!-- 是否启用 WebApp 全屏模式 -->
		<meta name="HandheldFriendly" content="true" />
		<!-- 针对手持设备优化，主要是针对一些老的不识别viewport的浏览器，比如黑莓 -->
		<meta name="author" content="Jack" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../../js/flexible.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/jquery_css/jquery-weui.css" />
		<link rel="stylesheet" type="text/css" href="../../style/main.css" />
		<link rel="stylesheet" type="text/css" href="../../style/icon.css" />
		<link rel="stylesheet" type="text/css" href="../../style/null.css"/>	
	</head>

	<body class="body-bg">
		<div class="header-nav is-postion">
			<div class="cen-mony">
				<div class="header-flex">
					<i class="return-2" onclick="window.history.go(-1)"></i>
				</div>
				<div class="header-flex">订单列表</div>
				<div class="header-flex"></div>
			</div>
		</div>
		<div class="top-my-UDC" id="all-UDC-list" style="width: 100%;margin-top: 1.15rem;">
			<!--<div class="cash-details-items">
				<div class="cash-details-cen">
					<div class="detail-flex">
						<div class="cash-dat-tit ssit">卖出UDC，获得</div>
						<div>余额：9555</div>
						<div>运营商：联通</div>
						<div>套餐：59</div>
					</div>
					<div class="detail-flex">
						<div class="ssit cash-color1">1.000</div>
						<div class="cash-times">2020-04-07</div>
					</div>
				</div>
			</div>
			<div class="cash-details-items">
				<div class="cash-details-cen">
					<div class="detail-flex">
						<div class="cash-dat-tit ssit">卖出UDC，获得</div>
						<div>余额：9555</div>
					</div>
					<div class="detail-flex">
						<div class="ssit cash-color2">1.000</div>
						<div class="cash-times">2020-04-07</div>
					</div>
				</div>
			</div>-->

		</div>
		<!--没有信息的时候-->
		<div class="null-data">
			<img src="../../images/null_data.png" alt="" />
			<div id="available">您还没有相关记录~</div>
		</div>
		
		<div class="weui-loadmore" id="loading">
	        <i class="weui-loading"></i>
	        <span class="weui-loadmore__tips">正在加载</span>
   		</div>

	</body>
	<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/weiUI/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/api_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/api/port_url.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/md5/md5.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../js/md5/access.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		var user_arr = JSON.parse(sessionStorage.getItem('users_info'));
		$(function() {
			MDC_detail_list();
		})
		
		
		
		
		var data_length='';//总页数
	    var page=1;//当前页
	    var pageSize=10;//每页显示几条
		
		var loading = false;  //状态标记 这个变量主要是用来控制触发次数，官网也有说明，事件可能会触发多次
	    $(document.body).infinite().on("infinite", function() {
	        $("#loading").css("display","block");//显示 加载中图标
	        if(loading) return;
	        loading = true;	            
            if(data_length<10||data_length==0){
	            $(document.body).destroyInfinite();//到最后一页时，销毁它
	            $("#loading>i").css("display","none");
	            $("#loading>span").html("到底啦~").css("color","#BDBDBD");
            }else{
            	MDC_detail_list();
            }
	    });
		//获取数据
	    function delOrder(id){
			if(confirm('操作不可逆，您确定删除订单？')) {
				$.ajax({
					url: config_URL.api+'user/delOrder', //请求的url地址
					dataType: "json", //返回格式为json
					data: {
						access_token: '047aefb0ad3570e95ebb7ba69a8a5791',
						user_token: user_arr.user_token,
						user_id:user_arr.id,
						id: id,
					},
					type: "POST", //请求方式
					success: function(res) {
						var data = res.data;
						if(res.code == 0) {
							$.toast('删除成功！', "text");								
							location.reload();
						} else {
							$.toast(res.msg, "text");
						}
					}
				})
	
			}
		}
		//获取数据
	    function MDC_detail_list(){
	        $.ajax({
				url: config_URL.api+URL.myOrderList, //请求的url地址
				dataType: "json", //返回格式为json
				data: {
					access_token: '047aefb0ad3570e95ebb7ba69a8a5791',
					user_token: user_arr.user_token,
					user_id:user_arr.id,
					page: page,
					list_rows: pageSize
				},
				type: "POST", //请求方式
				success: function(res) {
					console.log(res);
					var MDC_html = '';
					if(res.code == 0) {
						var data = res.data;
						var list_html = '';
						var is_color = '';
						//$('#mdc-num-all').text(data.counts.count);
						//这里计算出总页数。。一般是后台给的
	            		//countPage=Math.ceil((data.length)/pageSize);
	            			data_length =  data.length;
	            			if(data.length == 0) {
								$('.null-data').show();
							}else{
								$('.null-data').hide();
							}
							
	            			for(var i in data){
	            				if(data[i].status == 0){
	            					is_color = '';
									status='待审核';
	            				}else if(data[i].status == 1){
	            					is_color = 'cash-color1';
									status='审核通过';
	            				}else{
									is_color = 'cash-color2';
									status='已拒绝';
								}
	            				list_html+=
										'			<div class="cash-details-items">'+
										'				<div class="cash-details-cen">'+
										'					<div class="detail-flex">'+
										'						<div class="cash-dat-tit ssit">'+data[i].name+'</div>'+
										'						<div>电话：'+data[i].phone+'</div>'+
										'						<div>套餐：'+data[i].yys+' '+data[i].title+'</div>'+
										
										'					</div>'+
										'					<div class="detail-flex">'+
										'						<div class="ssit '+is_color+'">'+status+'</div>'+
										'						<div>担保方式：'+data[i].dbfs+'</div>'+
										'						<div>'+data[i].create_time+'</div>'+
										'					</div>'+
										'				</div>'+
										'				<div class="cash-details-cen">'+
										'						<span>地址：'+data[i].address+'</span>'+	
										'				</div>';
								if(data[i].status == 2){
									list_html+='				<div class="cash-details-cen">'+
											'						<span class="cash-color2">拒绝理由：'+data[i].beizhu+'</span>'+	
											'				</div>'+
											'				<div class="cash-details-cen" style="width:30%">'+
											'						<button style="text-align:center;width:100%;padding:5px 0;" onclick="delOrder('+data[i].id+')">删除</button>'+	
											'				</div>';
								}
										
								list_html+='			</div>';
								
	            				
	            			}
	            			$('#all-UDC-list').append(list_html);
	            		
	            		
	            		loading = false;//会多次触发，所以 需要请求完成数据 才能继续触发	            
	           			$("#loading").css("display","none");//数据加载完隐藏加载提示
						

					} else if(res.code == 1000005) {
						$.toast('你的账号已在其地方登录，请重新登录！', "text");
						setTimeout(function() {
							window.parent.location.href = '../login/login.html'
						}, 3000)

					} else {
						$.toast(res.msg, "text");
					}

				},
				error: function(rul) {
					console.log('网络出错')
				}
			});
	        page++;
	        
	        
	    }
	</script>
</html>